#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int sumCount(int n)
    {
        int ret = 0;
        while (n)
        {
            ret += n % 10;
            n /= 10;
        }
        return ret;
    }

    int differenceOfSum(vector<int>& nums) {
        int sum1 = 0, sum2 = 0, n = nums.size();
        for (int i = 0; i < n; i++)
        {
            sum1 += nums[i];
            sum2 += sumCount(nums[i]);
        }
        return max(sum1 - sum2, sum2 - sum1);
    }
};